""" Hames: a functional testing framework for Google App Engine Python

Docs and examples: http://code.google.com/p/hames/

Copyright 2012 VendAsta Technologies Inc.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
"""

class FunctionalTest(object):
    """
    Implement descendants of this class. You must specify the following:

    - NAME: the name of the test case, e.g., "Data Aggregation"
    - CATEGORY (optional): the name of the test case category (for the catalogue)
    """
    def __init__(self):
        self.messages = []

    def process(self, form):
        raise NotImplementedError('You must implement a process(form) method.')

    @classmethod
    def category_name(cls):
        return getattr(cls, 'CATEGORY', '')

    @classmethod
    def description(cls):
        return getattr(cls, 'DESCRIPTION', '')

    @classmethod
    def screen_name(cls):
        """
        Generates a name of test for on the screen.
        """
        return getattr(cls, 'NAME', cls.qualified_name())

    @classmethod
    def qualified_name(cls):
        """
        Generates a full name ('some.package.MyFunctionalTest')
        """
        return '%s.%s' % (cls.__module__, cls.__name__)

    @classmethod
    def url_name(cls):
        """
        Generates a string suitable for the url such that this class can be lifted later.
        """
        return cls.qualified_name()
